/*java jdk 1.7+
# -*- coding: utf-8 -
'''
Created on 2020年05月10日
@author: zxyong 13738196011
'''*/

package com.utils;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.json.JSONObject;

import com.zxy.business.Ope_DB_Cent;
import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;
import com.zxy.db_Self.Db_Common_Self;
import com.zxy.model.T_PROC_INPARAM;
import com.zxy.model.T_PROC_NAME;
import com.zxy.model.T_PROC_RETURN;

//根据h5模板生成对应前端文件
public class IN_A01_TTT999 implements com.zxy.common.ParamName_InterFace
{
	public StringBuilder			strResult			= new StringBuilder();
	public String					user_main_id				= null;
	public String					session_id			= null;
	public String					param_name			= null;
	public String					param_value1		= null;
	public String					param_value2		= null;
	public String					param_value3		= null;
	public String					param_value4		= null;
	public String					param_value5		= null;
	public String					param_value6		= null;
	public String					param_value7		= null;
	public String					param_value8		= null;
	public String					param_value9		= null;
	public String					param_value10		= null;
	// template地址
	private String					uploadPath			= "";
	private List<T_PROC_NAME>		t_proc_name_list	= null;
	private List<app_tag>			app_tag_list		= null;
	private List<T_PROC_RETURN>		T_PROC_RETURN_list	= null;
	private List<app_tag_column>	app_tag_column_list	= null;
	private t_page_info				temt_page_info		= new t_page_info();
	private String					TemJsonName			= "";

	// 演示h5部署地址
	private String					DemoUrl				= "/data/usr/local/webapps/cdi_CenterData/";	// "F:\\zxyong\\Android_App\\java_app\\center_data_lib\\assets\\App_FrameWork";
	private String					CentPath			= "";
	private int						funIndex			= 0;
	private int						funSubIndex			= 0;
	private int						funCallSubIndex		= 0;
	private String					temH5				= "";
	private List<tag_page>			tag_page_list		= null;

	public void init_start()
	{
		temH5 = Get_app_frame();
		DemoUrl += temH5;
		if(!param_value6.equals("") && param_value6.indexOf("/") != -1)
		{
			CentPath = param_value6.substring(0,param_value6.indexOf("/"));
			param_value6 = param_value6.substring(param_value6.indexOf("/")
					+ 1,param_value6.length());
		}
		if(com.zxy.common.Com_Para.UpLoad_File.equals(""))
		{
			uploadPath = GetAbsPath();// + "android_app";
		}else
		{
			uploadPath = com.zxy.common.Com_Para.UpLoad_File;// +
																// "//android_app";
		}

		FileHolderCreate(uploadPath + "//android_target");
		FileHolderCreate(uploadPath + "//android_target//"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd"));
		FileHolderCreate(uploadPath + "//android_target//"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd") + "//" + param_value6);
		FileHolderCreate(DemoUrl + "//" + CentPath);
		if(CentPath.equals(""))
			FileHolderCreate(DemoUrl + "//" + param_value6);

		Get_T_PROC_NAME();
		Get_app_tag_list();
		Get_app_tag_column();
		Get_t_page_info();
		Get_T_PROC_RETURN();
		// 生成TemplateIFaceLink.json代码

		String strTemMain_ID = "";
		for(String strTL: param_value1.split(","))
		{
			if(!strTemMain_ID.equals("") && strTL.equals(strTemMain_ID))
			{
				int nb = 0;
				for(app_tag atl: app_tag_list)
				{
					if(strTemMain_ID.equals(String.valueOf(atl.MAIN_ID)))
					{
						app_tag tt = new app_tag();
						tt.MAIN_ID = atl.MAIN_ID;
						tt.TAG_NAME = atl.TAG_NAME;
						tt.TAG_IMG = atl.TAG_IMG;
						tt.TAG_INFO = atl.TAG_INFO;
						tt.CREATE_DATE = atl.CREATE_DATE;
						tt.S_DESC = atl.S_DESC;
						tt.JS_FUN1 = atl.JS_FUN1;
						tt.JS_FUN2 = atl.JS_FUN2;
						tt.JS_FUN3 = atl.JS_FUN3;
						tt.JS_FUN4 = atl.JS_FUN4;
						tt.P_COUNT = atl.P_COUNT;
						tt.S_COUNT = atl.S_COUNT;
						tt.P_ID = atl.P_ID;
						tt.P_ID2 = atl.P_ID2;

						app_tag_list.add(nb,tt);
						break;
					}
					nb++;
				}
			}
			strTemMain_ID = strTL;
		}
		tag_page_list = new ArrayList<tag_page>();
		int iatn = -1;
		for(app_tag atn: app_tag_list)
		{
			tag_page tp = new tag_page();
			int ivv = 0;
			for(String strTag_ID: this.param_value1.split(","))
			{
				if(strTag_ID.equals(String.valueOf(atn.MAIN_ID))
						&& atn.MAIN_ID == iatn)
				{
					iatn = -1;
				}else if(strTag_ID.equals(String.valueOf(atn.MAIN_ID)))
				{
					tp.iIndex = ivv;
					tp.app_tag_MAIN_ID = strTag_ID;
					tp.app_tag_obj = atn;
					if(this.param_value5.split(",").length > ivv)
						tp.templateName = this.param_value5.split(",")[ivv];

					for(T_PROC_NAME at: t_proc_name_list)
					{
						if(this.param_value2.split(",").length > ivv
								&& !this.param_value2.split(",")[ivv].equals("")
								&& at.MAIN_ID == Integer.parseInt(this.param_value2.split(",")[ivv]))
						{
							tp.proc_name_obj = at;
							tp.proc_name_MAIN_ID = String.valueOf(at.MAIN_ID);
							break;
						}
					}
					if(this.param_value8.split(",").length > ivv)
					{
						tp.urlPathID = this.param_value8.split(",")[ivv];
						tp.urlPathStr = Get_menu_url(tp.urlPathID);
					}
					if(this.param_value10.split(",").length > ivv)
					{
						tp.P_MAIN_ID = this.param_value10.split(",")[ivv];

						for(T_PROC_RETURN tpr: T_PROC_RETURN_list)
						{
							if(!tp.P_MAIN_ID.equals("")
									&& tpr.MAIN_ID == Integer.valueOf(tp.P_MAIN_ID))
							{
								tp.P_MAIN_NAME = tpr.RETURN_NAME;
								break;
							}
						}
					}

					tp.tag_page_item_list = Get_tag_page_item(tp);
					tag_page_list.add(tp);
					break;
				}
				ivv++;
			}

			iatn = atn.MAIN_ID;
		}

		WriteTemplateFaceLink();
		WriteBizJs();
		WriteBizHtml();

		String strZipFile = "";
		strZipFile = ZipCodeFile();
		try
		{

			this.strResult.append("{\"" + param_name
					+ "\":[{\"s_result\":\"1\",\"error_desc\":\"\",\"biz_url\":\""
					+ strZipFile + "\",\"biz_name\":\""
					+ Com_Fun.DateTimeStr("yyyy-MM-dd") + param_value6
					+ ".zip\"}]}");
		}
		catch(Exception ee)
		{
			Com_Fun.debug_in(ee,this.toString());
		}
	}

	// 获取要素返回值对应关系表
	private List<tag_page_item> Get_tag_page_item(tag_page tp)
	{
		List<tag_page_item> lst = new ArrayList<tag_page_item>();
		for(app_tag_column apc: app_tag_column_list)
		{
			int vv = 0;
			if(param_value3.split(",").length > tp.iIndex)
			{
				for(String col: param_value3.split(",")[tp.iIndex].split("\\|"))
				{
					if(!col.equals("") && apc.MAIN_ID == Integer.valueOf(col))
					{
						tag_page_item tpi = new tag_page_item();
						tpi.TAG_VALUE = apc.TAG_VALUE;
						tpi.TAG_DESC = apc.TAG_DESC;
						String ret = param_value4.split(",")[tp.iIndex].split("\\|")[vv];
						for(T_PROC_RETURN tpr: T_PROC_RETURN_list)
						{
							if(!ret.equals("")
									&& tpr.MAIN_ID == Integer.valueOf(ret))
							{
								tpi.RETURN_NAME = tpr.RETURN_NAME;
								break;
							}
						}
						lst.add(tpi);
						vv++;
						break;
					}else
					{
						vv++;
					}
				}
			}
		}
		return lst;
	}

	private String ZipCodeFile()
	{
		String strF = ZipFiles(uploadPath + "//android_target//"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd") + "//"
				+ param_value6,uploadPath + "//android_target//"
						+ Com_Fun.DateTimeStr("yyyy-MM-dd") + param_value6
						+ ".zip");
		if(!strF.equals("-1"))
			return "/android_target/" + Com_Fun.DateTimeStr("yyyy-MM-dd")
					+ param_value6 + ".zip";
		else
			return "";
	}

	private String ZipFiles(String sourPath, String targetPathFile)
	{
		// 创建zip输出流
		ZipOutputStream out = null;
		File sourceFile = null;
		try
		{
			out = new ZipOutputStream(new FileOutputStream(targetPathFile));
			// bos = new BufferedOutputStream(out);
			sourceFile = new File(sourPath);
			// 调用函数
			compress(out,sourceFile,sourceFile.getName());
			out.close();
		}
		catch(Exception ee)
		{
			Com_Fun.debug_in(ee,this.toString());
			targetPathFile = "";
		}
		return targetPathFile;
	}

	private void compress(ZipOutputStream out, File sourceFile, String base) throws Exception
	{
		// 如果路径为目录（文件夹）
		if(sourceFile.isDirectory())
		{
			// 取出文件夹中的文件（或子文件夹）
			File[] flist = sourceFile.listFiles();

			if(flist.length == 0)// 如果文件夹为空，则只需在目的地zip文件中写入一个目录进入点
			{
				out.putNextEntry(new ZipEntry(base + "/"));
			}else
			// 如果文件夹不为空，则递归调用compress，文件夹中的每一个文件（或文件夹）进行压缩
			{
				for(int i = 0;i < flist.length;i++)
				{
					compress(out,flist[i],base + "/" + flist[i].getName());
				}
			}
		}else
		// 如果不是目录（文件夹），即为文件，则先写入目录进入点，之后将文件写入zip文件中
		{
			FileInputStream fos = new FileInputStream(sourceFile);
			// BufferedInputStream bis = new BufferedInputStream(fos);
			out.putNextEntry(new ZipEntry(base));
			int tag;
			// 将源文件写入到zip文件中
			while((tag = fos.read()) != -1)
			{
				out.write(tag);
			}
			fos.close();
		}
	}

	private String GetAbsPath()
	{
		String strResult = Com_Para.class.getProtectionDomain().getCodeSource().getLocation().getPath();
		int iLength = strResult.lastIndexOf("WEB-INF" + Com_Para.zxyPath);

		String os = System.getProperty("os.name");
		if(os.toLowerCase().startsWith("win"))
		{
			if(iLength > 0)
				return strResult.substring(1,iLength);// + "/";
			else
				return strResult.substring(1,strResult.length());// + "/";
		}else
		{
			if(iLength > 0)
				return strResult.substring(0,iLength);// + "/";
			else
				return strResult.substring(0,strResult.length());// + "/";
		}
	}

	private String Get_app_frame()
	{
		String strResult = "";
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from app_frame where MAIN_ID = '"
				+ this.param_value9 + "'");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				strResult = Com_Fun.NoNull(rs.getString("S_DESC"));
				break;
			}
		}
		catch(Exception es)
		{
			Com_Fun.debug_in(es,this.toString(),strSql.toString());
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return strResult;
	}

	private void Get_T_PROC_RETURN()
	{
		List<T_PROC_RETURN> tdlist = new ArrayList<T_PROC_RETURN>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from t_proc_return where MAIN_ID in('"
				+ this.param_value4.replace(",","','").replace("\\|","','")
				+ "','"
				+ this.param_value10.replace(",","','").replace("\\|","','")
				+ "')");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_PROC_RETURN tdc = new T_PROC_RETURN();
				tdc.MAIN_ID = rs.getInt("MAIN_ID");
				tdc.PROC_ID = rs.getInt("PROC_ID");
				tdc.RETURN_NAME = Com_Fun.NoNull(rs.getString("RETURN_NAME"));
				tdc.RETURN_TYPE = Com_Fun.NoNull(rs.getString("RETURN_TYPE"));
				tdc.IS_IMG = rs.getInt("IS_IMG");
				if(rs.getObject("IS_URLENCODE") != null)
					tdc.IS_URLENCODE = rs.getInt("IS_URLENCODE");
				tdc.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tdlist.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_RETURN]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_RETURN]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		T_PROC_RETURN_list = tdlist;
	}

	private void Get_app_tag_column()
	{
		List<app_tag_column> tdlist = new ArrayList<app_tag_column>();
		StringBuilder strSql = new StringBuilder();
		strSql.append("select * from app_tag_column where MAIN_ID in('"
				+ this.param_value3.replace(",","','").replace("\\|","','")
				+ "')");
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				app_tag_column tdc = new app_tag_column();
				tdc.MAIN_ID = rs.getInt("MAIN_ID");
				tdc.TAG_ID = rs.getInt("TAG_ID");
				tdc.TAG_VALUE = Com_Fun.NoNull(rs.getString("TAG_VALUE"));
				tdc.TAG_DESC = Com_Fun.NoNull(rs.getString("TAG_DESC"));
				tdc.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				tdlist.add(tdc);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_app_tag_column]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_app_tag_column]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		app_tag_column_list = tdlist;
	}

	private void Get_app_tag_list()
	{
		StringBuilder strSql = new StringBuilder();
		if(this.param_value1 != "")
		{
			strSql.append("select a.MAIN_ID,a.FRAME_ID,a.TAG_NAME,a.TAG_IMG,a.TAG_INFO,a.CREATE_DATE,"
					+ "a.S_DESC,a.JS_FUN1,a.JS_FUN2,a.JS_FUN3,a.JS_FUN4,b.S_COUNT,c.P_COUNT,c.TAG_ID as 'P_ID',"
					+ "if(c.P_COUNT is null,a.MAIN_ID,c.TAG_ID) as P_ID2 from app_tag a "
					+ "left join (select count(1) as S_COUNT,TAG_ID from app_tag_sub where SUB_ID in ('"
					+ this.param_value1.replace(",","','")
					+ "') group by TAG_ID) b on a.MAIN_ID = b.TAG_ID "
					+ "left join (select count(1) as P_COUNT,SUB_ID,TAG_ID from app_tag_sub where TAG_ID in ('"
					+ this.param_value1.replace(",","','")
					+ "') group by SUB_ID,TAG_ID) c on a.MAIN_ID = c.SUB_ID "
					+ "where a.MAIN_ID in ('"
					+ this.param_value1.replace(",","','")
					+ "') order by P_ID2,c.P_COUNT asc");
		}
		Db_Common_Self dbc_ic = new Db_Common_Self();
		List<app_tag> tdList = new ArrayList<app_tag>();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				app_tag td = new app_tag();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.TAG_IMG = Com_Fun.NoNull(rs.getString("TAG_IMG"));
				td.TAG_INFO = Com_Fun.NoNull(rs.getString("TAG_IMG"));
				td.TAG_NAME = Com_Fun.NoNull(rs.getString("TAG_NAME"));
				td.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				td.JS_FUN1 = Com_Fun.NoNull(rs.getString("JS_FUN1"));
				td.JS_FUN2 = Com_Fun.NoNull(rs.getString("JS_FUN2"));
				td.JS_FUN3 = Com_Fun.NoNull(rs.getString("JS_FUN3"));
				td.JS_FUN4 = Com_Fun.NoNull(rs.getString("JS_FUN4"));
				td.P_COUNT = rs.getInt("P_COUNT");
				td.S_COUNT = rs.getInt("S_COUNT");
				td.P_ID = rs.getInt("P_ID");
				td.P_ID2 = rs.getInt("P_ID2");
				tdList.add(td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_app_tag_list]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_app_tag_list]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		app_tag_list = tdList;
	}

	private String Get_menu_url(String iMAIN_ID)
	{
		String strUrlPath = "";
		StringBuilder strSql = new StringBuilder();
		if(this.param_value1 != "")
		{
			strSql.append("select * from app_menu where MAIN_ID ='" + iMAIN_ID
					+ "'");
		}
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				strUrlPath = Com_Fun.NoNull(rs.getString("MENU_URL"));
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_menu_url]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_menu_url]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		return strUrlPath;
	}

	private void Get_t_page_info()
	{
		StringBuilder strSql = new StringBuilder();
		if(this.param_value1 != "")
		{
			strSql.append("select * from t_page_info where MAIN_ID ='"
					+ this.param_value7 + "'");
		}
		Db_Common_Self dbc_ic = new Db_Common_Self();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				temt_page_info.MAIN_ID = rs.getInt("MAIN_ID");
				temt_page_info.PAGE_CODE = Com_Fun.NoNull(rs.getString("PAGE_CODE"));
				temt_page_info.PAGE_TITLE = Com_Fun.NoNull(rs.getString("PAGE_TITLE"));
				temt_page_info.PAGE_URL = Com_Fun.NoNull(rs.getString("PAGE_URL"));
				temt_page_info.S_DESC = Com_Fun.NoNull(rs.getString("S_DESC"));
				temt_page_info.JS_URL = Com_Fun.NoNull(rs.getString("JS_URL"));
				temt_page_info.CREATE_DATE = java.util.Objects.equals(rs.getDate("CREATE_DATE"),null) ? (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1900-01-01 00:00:00")) : (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(rs.getString("CREATE_DATE")));// rs.getDate("LIMIT_DATE");//rs.getDate("LIMIT_DATE");
				break;
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_t_page_info]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_t_page_info]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
	}

	private void Get_T_PROC_NAME()
	{
		StringBuilder strSql = new StringBuilder();
		if(this.param_value2 != "")
		{
			strSql.append("select * from T_PROC_NAME where MAIN_ID in ('"
					+ this.param_value2.replace(",","','") + "')");
		}
		Db_Common_Self dbc_ic = new Db_Common_Self();
		List<T_PROC_NAME> tdList = new ArrayList<T_PROC_NAME>();
		ResultSet rs = null;
		try
		{
			rs = dbc_ic.Common_Sql(strSql);
			while(rs.next())
			{
				T_PROC_NAME td = new T_PROC_NAME();
				td.MAIN_ID = rs.getInt("MAIN_ID");
				td.DB_ID = rs.getInt("DB_ID");
				td.INF_CN_NAME = Com_Fun.NoNull(rs.getString("INF_CN_NAME"));
				td.INF_EN_NAME = Com_Fun.NoNull(rs.getString("INF_EN_NAME"));
				td.INF_EN_SQL = Com_Fun.NoNull(rs.getString("INF_EN_SQL"));
				td.INF_TYPE = Com_Fun.NoNull(rs.getString("INF_TYPE"));
				td.REFLECT_IN_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_IN_CLASS"));
				td.REFLECT_OUT_CLASS = Com_Fun.NoNull(rs.getString("REFLECT_OUT_CLASS"));
				tdList.add(td);
			}
		}
		catch(SQLException e)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n"
					+ strSql.toString() + " " + e.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		catch(Exception es)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行SQL出错[Get_T_PROC_NAME]\r\n"
					+ strSql.toString() + " " + es.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		finally
		{
			try
			{
				if(rs != null)
				{
					rs.getStatement().close();
					rs.close();
				}
			}
			catch(SQLException e)
			{
			}
		}
		t_proc_name_list = tdList;
	}

	private void FileHolderCreate(String urlPath)
	{
		// 判断目标文件夹是否存在
		File file = new File(urlPath);
		if(!file.exists() && !file.isDirectory())
		{
			file.mkdir();
		}
	}

	// selMain_ID "6,8" param_value1
	// PorcMAIN_ID "5,2" param_value2
	// tagColumnID "12|13,18|19|20|21" param_value3
	// ProcReturnID "31|32,8|9|10|10" param_value4
	// templateName param_value5
	// urlPathID param_value8
	// P_MAIN_ID param_value10

	private String WriteBizHtml()
	{
		String temFileName = uploadPath + "//android_target//"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd") + "//" + param_value6 + "//"
				+ param_value6 + ".html";
		String temDemoUrl = "";
		if(CentPath.equals(""))
			temDemoUrl = DemoUrl + "/" + param_value6 + "/" + param_value6
					+ ".html";
		else
			temDemoUrl = DemoUrl + "/" + CentPath + "/" + param_value6
					+ ".html";
		BufferedWriter sw = null;
		BufferedWriter sw2 = null;
		FileInputStream fr = null;
		InputStreamReader is = null;
		BufferedReader br = null;
		try
		{
			File fiFile = new File(temFileName);
			File readfiFile = new File(uploadPath + "/android_template/" + temH5
					+ "/biz_html/biz_01.html");

			if(!readfiFile.exists())
			{
				strResult.append("{\"" + param_name + "\":[{\""
						+ Com_Fun.getLowUpp("s_result") + "\":\"0\",\""
						+ Com_Fun.getLowUpp("error_desc") + "\":\"模板js文件不存在"
						+ "\"}]}");
				return "";
			}else if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}
			fiFile = new File(temDemoUrl);
			if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}
			sw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temFileName,false),Com_Para.U_CODE));
			sw2 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temDemoUrl,false),Com_Para.U_CODE));

			fr = new FileInputStream(readfiFile);
			is = new InputStreamReader(fr,Com_Para.U_CODE);
			br = new BufferedReader(is);
			String NewHtmlTag = "";
			List<String> aryTag = new ArrayList<String>();
			while(true)
			{
				String line = br.readLine();
				if(java.util.Objects.equals(line,null))
					break;

				boolean bHtmlTagUse = false;
				if(line.indexOf("begin-->") != -1)
				{
					aryTag.clear();
					NewHtmlTag = "";
					for(app_tag at: app_tag_list)
					{
						if(line.indexOf("<!--" + at.TAG_NAME.split("_")[0]
								+ " begin-->") != -1)
						{
							bHtmlTagUse = true;
							int kk = 0;
							for(String temS: param_value1.split(","))
							{
								if(temS.equals(String.valueOf(at.MAIN_ID)))
								{
									aryTag.add(param_value5.split(",")[kk]);// (at.TAG_NAME);
								}
								kk++;
							}
							break;
						}
					}
					sw.write(line + "\r\n");
					sw2.write(line + "\r\n");
					if(!bHtmlTagUse)
					{
						sw.write("<!-- \r\n");
						sw2.write("<!-- \r\n");
					}else
						NewHtmlTag += line + "\r\n";
				}else if(line.indexOf("end-->") != -1)
				{
					for(app_tag at: app_tag_list)
					{
						if(line.indexOf("<!--" + at.TAG_NAME.split("_")[0]
								+ " end-->") != -1)
						{
							bHtmlTagUse = true;
							break;
						}
					}
					if(!bHtmlTagUse)
					{
						sw.write("--> \r\n");
						sw.write(line + "\r\n");
						sw2.write("--> \r\n");
						sw2.write(line + "\r\n");
					}else
					{
						sw.write(line + "\r\n");
						sw2.write(line + "\r\n");

						NewHtmlTag += line + "\r\n";
						for(int nn = 1;nn < aryTag.size();nn++)
						{
							String nTag = aryTag.get(nn);
							sw.write(NewHtmlTag.replace(nTag.substring(0,7)
									+ "001",nTag.replace("_template","")));
							sw2.write(NewHtmlTag.replace(nTag.substring(0,7)
									+ "001",nTag.replace("_template","")));
						}
						NewHtmlTag = "";
						aryTag.clear();
					}
				}else if(line.indexOf("../js/TemplateIFaceLink.json") != -1)
				{
					sw.write(line + "\r\n");
					sw.write("		<script src=\"" + this.TemJsonName
							+ "?callback=ReadTemplateIFaceLinkPage\" type=\"text/javascript\"></script>\r\n");
					sw2.write(line + "\r\n");
					sw2.write("		<script src=\"" + this.TemJsonName
							+ "?callback=ReadTemplateIFaceLinkPage\" type=\"text/javascript\"></script>\r\n");
				}else
				{
					if(line.indexOf("src=\"biz_01.js\"") != -1)
						line = line.replace("biz_01.js",param_value6 + ".js");
					sw.write(line + "\r\n");
					sw2.write(line + "\r\n");
					if(!NewHtmlTag.equals(""))
						NewHtmlTag += line + "\r\n";
				}
			}

			sw.close();
			sw2.close();
			fr.close();
			is.close();
			br.close();
		}
		catch(Exception ee)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行写入出错[WriteBizHtml]\r\n"
					+ ee.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		return "";
	}

	private String WriteBizJs()
	{
		String temFileName = uploadPath + "/android_target/"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd") + "//" + param_value6 + "//"
				+ param_value6 + ".js";
		String temDemoUrl = "";
		if(CentPath.equals(""))
			temDemoUrl = DemoUrl + "/" + param_value6 + "/" + param_value6
					+ ".js";
		else
			temDemoUrl = DemoUrl + "/" + CentPath + "/" + param_value6 + ".js";

		File fiFile = new File(temFileName);
		File readfiFile = new File(uploadPath + "/android_template/" + temH5
				+ "/biz_html/biz_01.js");
		BufferedWriter sw = null;
		BufferedWriter sw2 = null;

		FileInputStream fr = null;
		InputStreamReader is = null;
		BufferedReader br = null;
		try
		{
			if(!readfiFile.exists())
			{
				strResult.append("{\"" + param_name + "\":[{\""
						+ Com_Fun.getLowUpp("s_result") + "\":\"0\",\""
						+ Com_Fun.getLowUpp("error_desc") + "\":\"模板js文件不存在"
						+ "\"}]}");
				return "";
			}else if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}

			fiFile = new File(temDemoUrl);
			if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}

			sw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temFileName,false),Com_Para.U_CODE));
			sw2 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temDemoUrl,false),Com_Para.U_CODE));
			fr = new FileInputStream(readfiFile);
			is = new InputStreamReader(fr,Com_Para.U_CODE);
			br = new BufferedReader(is);

			while(true)
			{
				String line = br.readLine();
				if(null == line)
					break;
				sw.write(line + "\r\n");
				sw2.write(line + "\r\n");
				if(line.indexOf("*biz begin*") != -1)
				{
					if(tag_page_list.size() > 0)
					{
						String strTV = AjaxCallBiz();// AjaxCall(tpn);
						sw.write(strTV);
						sw2.write(strTV);
					}
				}else if(line.indexOf("*biz step begin*") != -1)
				{
					int j = 0;
					for(tag_page tp: tag_page_list)
					{
						String TV = AjaxResult(j,tp);
						sw.write(TV);
						sw2.write(TV);
						j++;
					}
				}
			}

			sw.close();
			sw2.close();
			fr.close();
			is.close();
			br.close();
		}
		catch(Exception ee)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行写入出错[WriteBizJs]\r\n"
					+ ee.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
		return "";
	}

	private String AjaxResult(int j, tag_page tp)
	{
		String strInputData = "";
		if(j == 0)
		{
			Ope_DB_Cent odc = new Ope_DB_Cent();
			List<T_PROC_INPARAM> liINPARAM = odc.Get_T_PROC_INPARAM(tp.proc_name_obj.MAIN_ID);
			strInputData += "function Get_APP_USER_ZXY(data){\r\n";
			strInputData += "	if(data != null)\r\n";
			strInputData += "		APP_USER_ZXY = data;\r\n";
			strInputData += "	if(jsonReadCommonRes != null && typeof(jsonReadCommonRes) != \"undefined\" && jsonReadCommonRes.hasOwnProperty(\""
					+ tp.proc_name_obj.INF_EN_NAME + "\"))\r\n";
			strInputData += "	{\r\n";
			strInputData += "		" + tp.proc_name_obj.INF_EN_NAME + "_"
					+ String.valueOf(funIndex) + "(jsonReadCommonRes);\r\n";
			strInputData += "	}\r\n";
			strInputData += "	else if(APP_USER_ZXY != null && typeof(APP_USER_ZXY) != \"undefined\" && APP_USER_ZXY.hasOwnProperty(\""
					+ tp.proc_name_obj.INF_EN_NAME + "\"))\r\n";
			strInputData += "	{\r\n";
			strInputData += "		" + tp.proc_name_obj.INF_EN_NAME + "_"
					+ String.valueOf(funIndex) + "(APP_USER_ZXY);\r\n";
			strInputData += "	}\r\n";
			strInputData += "	else\r\n";
			strInputData += "	{\r\n";
			strInputData += "		//请传入对应接口参数\r\n";
			strInputData += "		var inputdata = {\"param_name\":\""
					+ tp.proc_name_obj.INF_EN_NAME
					+ "\",\"session_id\":session_id,\"login_id\":login_id";

			int i = 1;
			for(@SuppressWarnings("unused")
			T_PROC_INPARAM temTPI: liINPARAM)
			{
				strInputData += ",\"param_value" + String.valueOf(i)
						+ "\":\"\"";
				i++;
			}
			strInputData += "};\r\n";
			strInputData += "		get_ajax_baseurl(inputdata,\""
					+ tp.proc_name_obj.INF_EN_NAME + "_"
					+ String.valueOf(funIndex) + "\");\r\n";
			strInputData += "	}\r\n";
			strInputData += "}\r\n\r\n";
		}
		if(tp.app_tag_obj.P_COUNT > 0 && tp.proc_name_obj != null)
		{
			strInputData += AjaxResultCommonSub(j,tp);
		}else if(tp.proc_name_obj != null)
		{
			strInputData += AjaxResultCommon(j,tp);
		}
		return strInputData;
	}

	private String AjaxResultCommon(int j, tag_page tp)
	{
		String strInputData = "";
		strInputData += "function " + tp.proc_name_obj.INF_EN_NAME + "_"
				+ String.valueOf(funIndex) + "(input){\r\n";
		strInputData += "	data = input." + tp.proc_name_obj.INF_EN_NAME
				+ ";\r\n";
		strInputData += "	var AAA_PATH = \"" + tp.urlPathStr + "\";\r\n";
		strInputData += "	var s_result = \"1\";\r\n";
		strInputData += "	var error_desc = \"\";\r\n";
		strInputData += "	for (var key in data[0]) {\r\n";
		strInputData += "		if (key == 's_result')\r\n";
		strInputData += "		{\r\n";
		strInputData += "			s_result = data[0].s_result;\r\n";
		strInputData += "			error_desc = data[0].error_desc;\r\n";
		strInputData += "		}\r\n";
		strInputData += "	}\r\n";
		strInputData += "	if (s_result == \"0\") {\r\n";
		strInputData += "		swal(\"获取数据异常！\", \"获取数据异常！:"
				+ tp.proc_name_obj.INF_EN_NAME
				+ "\"+error_desc, \"warning\");\r\n";
		strInputData += "	}\r\n";
		strInputData += "	else\r\n";
		strInputData += "	{\r\n";
		if(!tp.app_tag_obj.JS_FUN1.equals(""))
			strInputData += "		" + tp.app_tag_obj.JS_FUN1 + "\r\n";
		strInputData += "		$.each(data,function (i, obj)\r\n";
		strInputData += "		{\r\n";
		if(!tp.app_tag_obj.JS_FUN2.equals(""))
			strInputData += "			" + tp.app_tag_obj.JS_FUN2 + "\r\n";
		strInputData += "			var template_temp = set_template("
				+ tp.app_tag_obj.TAG_NAME + ",\"" + tp.app_tag_obj.TAG_NAME
				+ "\",obj,\"" + tp.proc_name_obj.INF_EN_NAME
				+ "\").replace(\"$AAA\",AAA_PATH);\r\n";
		if(!tp.app_tag_obj.JS_FUN3.equals(""))
			strInputData += "			" + tp.app_tag_obj.JS_FUN3 + "\r\n";

		if(tp.app_tag_obj.S_COUNT > 0)
		{
			// 循环获取嵌套模板调用
			for(tag_page temTP: tag_page_list)
			{
				if(tp.app_tag_obj.MAIN_ID == temTP.app_tag_obj.P_ID
						&& temTP.app_tag_obj.P_COUNT > 0)
				{
					strInputData += "			template_temp = "
							+ temTP.proc_name_obj.INF_EN_NAME + "_sub_"
							+ String.valueOf(funCallSubIndex)
							+ "(template_temp,obj);\r\n";
					funCallSubIndex++;
				}
			}
		}

		strInputData += "			$(\"#"
				+ tp.templateName.replace("_template","")
				+ "\").append(template_temp);\r\n";
		if(!tp.app_tag_obj.JS_FUN4.equals(""))
			strInputData += "			" + tp.app_tag_obj.JS_FUN4 + "\r\n";
		strInputData += "		});\r\n";
		strInputData += "	}\r\n";
		strInputData += "	layer.close(ly_index);\r\n";
		funIndex++;

		for(int i = j + 1;i < tag_page_list.size();i++)
		{
			tag_page tpT = tag_page_list.get(i);
			if(tpT.app_tag_obj.P_COUNT <= 0)
			{
				strInputData += AjaxCall(tpT.proc_name_obj);
				break;
			}
		}

		for(int nk = 1;nk < tag_page_list.size();nk++)
		{
			if(tag_page_list.get(tag_page_list.size()
					- nk).app_tag_obj.P_COUNT <= 0
					&& tag_page_list.get(tag_page_list.size()
							- nk).proc_name_obj != null)
			{
				if(tp.app_tag_MAIN_ID == tag_page_list.get(tag_page_list.size()
						- nk).app_tag_MAIN_ID)
					strInputData += "	page_end();\r\n";
				else
					break;
			}
		}
		strInputData += "}\r\n\r\n";
		return strInputData;
	}

	private String AjaxResultCommonSub(int j, tag_page tp)
	{
		String strInputData = "";
		strInputData += "function " + tp.proc_name_obj.INF_EN_NAME + "_sub_"
				+ String.valueOf(funSubIndex)
				+ "(objtemplate_temp,objInput){\r\n";
		strInputData += "	data = objInput." + tp.proc_name_obj.INF_EN_NAME
				+ ";\r\n";
		strInputData += "	var AAA_PATH = \"" + tp.urlPathStr + "\";\r\n";
		strInputData += "	if(jsonReadCommonRes != null && typeof(jsonReadCommonRes) != \"undefined\" && jsonReadCommonRes.hasOwnProperty(\""
				+ tp.proc_name_obj.INF_EN_NAME + "\"))\r\n";
		strInputData += "	{\r\n";
		strInputData += "		data = jsonReadCommonRes."
				+ tp.proc_name_obj.INF_EN_NAME + ";\r\n";
		strInputData += "		$.each(data,function (i, obj){\r\n";
		strInputData += "			if(obj.P_ID == objInput.MAIN_ID)\r\n";
		strInputData += "			{\r\n";
		strInputData += "				objResult = $(objtemplate_temp);\r\n";
		strInputData += "				var template_temp = set_template("
				+ tp.app_tag_obj.TAG_NAME + ",\"" + tp.app_tag_obj.TAG_NAME
				+ "\",obj,\"" + tp.proc_name_obj.INF_EN_NAME
				+ "\").replace(\"$AAA\",AAA_PATH);\r\n";
		strInputData += "				objResult.find(\"#"
				+ tp.app_tag_obj.TAG_NAME.substring(0,11)
				+ "\"+objInput.MAIN_ID).append(template_temp);\r\n";
		strInputData += "				objtemplate_temp = objResult;\r\n";
		strInputData += "			}\r\n";
		strInputData += "		});\r\n";
		strInputData += "	}\r\n";
		strInputData += "	else if(APP_USER_ZXY != null && typeof(APP_USER_ZXY) != \"undefined\" && APP_USER_ZXY.hasOwnProperty(\""
				+ tp.proc_name_obj.INF_EN_NAME + "\"))\r\n";
		strInputData += "	{\r\n";
		strInputData += "		data = APP_USER_ZXY."
				+ tp.proc_name_obj.INF_EN_NAME + ";\r\n";
		strInputData += "		$.each(data,function (i, obj){\r\n";
		strInputData += "			if(obj.P_ID == objInput.MAIN_ID)\r\n";
		strInputData += "			{\r\n";
		strInputData += "				objResult = objtemplate_temp;\r\n";
		strInputData += "				var template_temp = $(set_template("
				+ tp.app_tag_obj.TAG_NAME + ",\"" + tp.app_tag_obj.TAG_NAME
				+ "\",obj,\"" + tp.proc_name_obj.INF_EN_NAME
				+ "\").replace(\"$AAA\",AAA_PATH));\r\n";
		strInputData += "				$(objResult).find(\"#"
				+ tp.app_tag_obj.TAG_NAME.replace("template","")
				+ "\"+objInput.MAIN_ID)[0].append($(template_temp));\r\n";
		strInputData += "				objtemplate_temp = objResult.toString();\r\n";
		strInputData += "			}\r\n";
		strInputData += "		});\r\n";
		strInputData += "	}\r\n";
		strInputData += "	return $(objtemplate_temp);\r\n";
		strInputData += "}\r\n\r\n";
		funSubIndex++;
		return strInputData;
	}

	private String AjaxCallBiz()
	{
		String strInputData = "";
		if(this.temt_page_info.MAIN_ID == -1)
		{
			strInputData += "	Get_APP_USER_ZXY(null);\r\n";
		}else
		{
			strInputData += "	//请传入对应接口参数\r\n";
			strInputData += "	if(jsonReadCommonRes != null && typeof(jsonReadCommonRes) != \"undefined\" && jsonReadCommonRes.hasOwnProperty(\"Get_APP_USER_ZXY\"))\r\n";
			strInputData += "	{\r\n";
			strInputData += "		Get_APP_USER_ZXY(jsonReadCommonRes);\r\n";
			strInputData += "	}\r\n";
			strInputData += "	else\r\n";
			strInputData += "	{\r\n";
			strInputData += "		var inputdata = {\"param_name\":\"APP_USER_ZXY\",\"session_id\":session_id,\"login_id\":login_id,\"param_value1\":\""
					+ this.temt_page_info.PAGE_CODE + "\"};\r\n";
			strInputData += "		get_ajax_baseurl(inputdata,\"Get_APP_USER_ZXY\");\r\n";
			strInputData += "	}\r\n";
		}
		return strInputData;
	}

	private String AjaxCall(T_PROC_NAME tpn)
	{
		if(java.util.Objects.equals(tpn,null))
			return "";
		Ope_DB_Cent odc = new Ope_DB_Cent();
		List<T_PROC_INPARAM> liINPARAM = odc.Get_T_PROC_INPARAM(tpn.MAIN_ID);
		String strInputData = "";
		strInputData += "	if(jsonReadCommonRes != null && typeof(jsonReadCommonRes) != \"undefined\" && jsonReadCommonRes.hasOwnProperty(\""
				+ tpn.INF_EN_NAME + "\"))\r\n";
		strInputData += "	{\r\n";
		strInputData += "		" + tpn.INF_EN_NAME + "_"
				+ String.valueOf(funIndex) + "(jsonReadCommonRes);\r\n";
		strInputData += "	}\r\n	else if(APP_USER_ZXY != null && typeof(APP_USER_ZXY) != \"undefined\" && APP_USER_ZXY.hasOwnProperty(\""
				+ tpn.INF_EN_NAME + "\"))\r\n";
		strInputData += "	{\r\n";
		strInputData += "		" + tpn.INF_EN_NAME + "_"
				+ String.valueOf(funIndex) + "(APP_USER_ZXY);\r\n";
		strInputData += "	}\r\n	else\r\n	{\r\n";
		strInputData += "		//请传入对应接口参数\r\n		var inputdata = {\"param_name\":\""
				+ tpn.INF_EN_NAME
				+ "\",\"session_id\":session_id,\"login_id\":login_id";
		int i = 1;
		for(@SuppressWarnings("unused")
		T_PROC_INPARAM temTPI: liINPARAM)
		{
			strInputData += ",\"param_value" + String.valueOf(i) + "\":\"\"";
			i++;
		}
		strInputData += "};\r\n";
		strInputData += "		get_ajax_baseurl(inputdata,\"" + tpn.INF_EN_NAME
				+ "_" + String.valueOf(funIndex) + "\");\r\n";
		strInputData += "	}\r\n";
		return strInputData;
	}

	private void WriteTemplateFaceLink()
	{
		this.TemJsonName = param_value6 + ".json";
		String temFileName = uploadPath + "/android_target/"
				+ Com_Fun.DateTimeStr("yyyy-MM-dd") + "/" + param_value6 + "/"
				+ TemJsonName;
		String temDemoUrl = "";

		if(CentPath.equals(""))
			temDemoUrl = DemoUrl + "/" + param_value6 + "/" + TemJsonName;
		else
			temDemoUrl = DemoUrl + "/" + CentPath + "/" + TemJsonName;

		BufferedWriter sw = null;
		BufferedWriter sw2 = null;
		try
		{
			File fiFile = new File(temFileName);
			if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}
			fiFile = new File(temDemoUrl);
			if(!fiFile.exists())
			{
				fiFile.createNewFile();
			}
			sw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temFileName,false),Com_Para.U_CODE));
			sw2 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temDemoUrl,false),Com_Para.U_CODE));

			JSONObject jsoProc = new JSONObject(new LinkedHashMap());
			sw.write("ReadTemplateIFaceLinkPage(\r\n");
			sw2.write("ReadTemplateIFaceLinkPage(\r\n");

			for(int j = 0;j < param_value2.split(",").length;j++)
			{
				for(int i = 0;i < t_proc_name_list.size();i++)
				{
					T_PROC_NAME temTPN = t_proc_name_list.get(i);
					// 取数据序号
					if(!param_value2.split(",")[j].equals("")
							&& temTPN.MAIN_ID == Integer.valueOf(param_value2.split(",")[j]))
					{
						JSONObject jsotemplate = new JSONObject(new LinkedHashMap());
						if(jsoProc.has(temTPN.INF_EN_NAME))
							jsotemplate = jsoProc.getJSONObject(temTPN.INF_EN_NAME);
						String appKey = "";
						for(app_tag tr: app_tag_list)
						{
							if(!param_value1.split(",")[j].equals("")
									&& tr.MAIN_ID == Integer.valueOf(param_value1.split(",")[j]))
							{
								appKey = tr.TAG_NAME;
								break;
							}
						}
						String temStrP3 = param_value3.split(",")[j];
						String temStrP4 = param_value4.split(",")[j];
						String[] aryP3 = temStrP3.split("\\|");
						String[] aryP4 = temStrP4.split("\\|");
						JSONObject jsoP3_4 = new JSONObject(new LinkedHashMap());
						JSONObject jsotemEncode = new JSONObject(new LinkedHashMap());
						for(int n = 0;n < aryP3.length;n++)
						{
							String temKey = "";
							String temValue = "";

							for(app_tag_column tr: app_tag_column_list)
							{
								if(!aryP3[n].equals("")
										&& tr.MAIN_ID == Integer.valueOf(aryP3[n]))
								{
									temKey = tr.TAG_VALUE;
									break;
								}
							}

							for(T_PROC_RETURN tr: T_PROC_RETURN_list)
							{
								if(!aryP4[n].equals("")
										&& tr.MAIN_ID == Integer.valueOf(aryP4[n]))
								{
									temValue = tr.RETURN_NAME;
									if(tr.IS_URLENCODE == 1)
									{
										jsotemEncode.put(temValue,"1");
									}
									break;
								}
							}
							jsoP3_4.put(temKey,temValue);
						}
						jsotemplate.put(appKey,jsoP3_4);
						jsotemplate.put(temTPN.INF_EN_NAME
								+ "_ENCODE",jsotemEncode);
						jsoProc.put(temTPN.INF_EN_NAME,jsotemplate);
					}
				}
			}
			sw.write(jsoProc.toString() + "\r\n");
			sw.write(")");
			sw.close();

			sw2.write(jsoProc.toString() + "\r\n");
			sw2.write(")");
			sw2.close();
		}
		catch(Exception ee)
		{
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder("执行写入出错[WriteTemplateFaceLink]\r\n"
					+ ee.getMessage()));
			try
			{
				uL.WriteLog();
			}
			catch(IOException e1)
			{
			}
		}
	}

	private void ReadDataTemplateIFaceLink(String strTFileName) throws IOException
	{
		File fiFile = new File(strTFileName);
		FileInputStream fr = null;
		if(!fiFile.exists())
		{
			strResult.append("{\"" + param_value3.replace(".dat","")
					+ "\":[{\"" + Com_Fun.getLowUpp("s_result") + "\":\"0\",\""
					+ Com_Fun.getLowUpp("error_desc") + "\":\"数据结果未生成,检查参数"
					+ "\"}]}");
		}else
		{
			InputStreamReader is = null;
			BufferedReader br = null;
			try
			{
				fr = new FileInputStream(strTFileName);
				is = new InputStreamReader(fr,Com_Para.U_CODE);
				br = new BufferedReader(is);
				while(true)
				{
					String line = br.readLine();
					if(java.util.Objects.equals(line,null))
						break;
					strResult.append(line);
				}
			}
			catch(Exception ex)
			{
				ex.printStackTrace();
			}
			finally
			{
				is.close();
				br.close();
				fr.close();
			}
		}
	}

	public StringBuilder getStrResult()
	{
		return strResult;
	}

	public void setStrResult(StringBuilder strResult)
	{
		this.strResult = strResult;
	}

	public String getUser_main_id()
	{
		return user_main_id;
	}

	public void setUser_main_id(String user_main_id)
	{
		this.user_main_id = user_main_id;
	}

	public String getSession_id()
	{
		return session_id;
	}

	public void setSession_id(String session_id)
	{
		this.session_id = session_id;
	}

	public String getParam_name()
	{
		return param_name;
	}

	public void setParam_name(String param_name)
	{
		this.param_name = param_name;
	}

	public String getParam_value1()
	{
		return param_value1;
	}

	public void setParam_value1(String param_value1)
	{
		this.param_value1 = param_value1;
	}

	public String getParam_value2()
	{
		return param_value2;
	}

	public void setParam_value2(String param_value2)
	{
		this.param_value2 = param_value2;
	}

	public String getParam_value3()
	{
		return param_value3;
	}

	public void setParam_value3(String param_value3)
	{
		this.param_value3 = param_value3;
	}

	public String getParam_value4()
	{
		return param_value4;
	}

	public void setParam_value4(String param_value4)
	{
		this.param_value4 = param_value4;
	}

	public String getParam_value5()
	{
		return param_value5;
	}

	public void setParam_value5(String param_value5)
	{
		this.param_value5 = param_value5;
	}

	public String getParam_value6()
	{
		return param_value6;
	}

	public void setParam_value6(String param_value6)
	{
		this.param_value6 = param_value6;
	}

	public String getParam_value7()
	{
		return param_value7;
	}

	public void setParam_value7(String param_value7)
	{
		this.param_value7 = param_value7;
	}

	public String getParam_value8()
	{
		return param_value8;
	}

	public void setParam_value8(String param_value8)
	{
		this.param_value8 = param_value8;
	}

	public String getParam_value9()
	{
		return param_value9;
	}

	public void setParam_value9(String param_value9)
	{
		this.param_value9 = param_value9;
	}

	public String getParam_value10()
	{
		return param_value10;
	}

	public void setParam_value10(String param_value10)
	{
		this.param_value10 = param_value10;
	}
}